package thread;

public class Demo_203 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("我是一个线程，我还活着");
            }
            System.out.println(Thread.currentThread().getName() + "我即将死去");
        },"拉布拉猪");
        System.out.println("线程" + t1.getName() + "的ID：" + t1.getId());
        System.out.println("线程" + t1.getName() + "的名称:" + t1.getName());
        System.out.println("线程" + t1.getName() + "的状态:" + t1.getState());
        System.out.println("线程" + t1.getName() + "的优先级:" + t1.getPriority());
        System.out.println("线程" + t1.getName() + "的后台进程:" + t1.isDaemon());
        System.out.println("线程" + t1.getName() + "是否活着:" + t1.isAlive());
        System.out.println("线程" + t1.getName() + "是否被中断:" + t1.isInterrupted());
        t1.start();
        while (t1.isAlive()) {
            //System.out.println(t1.getName()+"状态:" + t1.getState());
        }
        System.out.println(Thread.currentThread().getName() + "状态：" + Thread.currentThread().getState());
        Thread t2 = new Thread();
        Thread t3 = t2;
    }
}
